package com.abso.mp3tunes.locker.ui.viewers;

import com.abso.mp3tunes.locker.core.data.Album;
import com.abso.mp3tunes.locker.core.data.Track;
import com.abso.mp3tunes.locker.ui.ILockerConstants;

/**
 * A specialized label provider for the search tree viewer.
 */
public class SearchViewerLabelProvider extends LockerViewerLabelProvider {

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.abso.mp3tunes.locker.ui.viewers.LockerViewerLabelProvider#getText(java.lang.Object)
	 */
	public String getText(Object element) {
		if (element instanceof Track) {
			Track track = (Track) element;
			if (Boolean.TRUE.equals(track.getData(ILockerConstants.SEARCH_KEY))) {
				return getTrackText(track, false, true);
			} else {
				return getTrackText(track, true, false);
			}
		} else if (element instanceof Album) {
			Album album = (Album) element;
			if (Boolean.TRUE.equals(album.getData(ILockerConstants.SEARCH_KEY))) {
				return getAlbumText(album, true);
			} else {
				return getAlbumText(album, false);
			}
		} else {
			return super.getText(element);
		}
	}

}
